<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 接收参数
    // console.log(window.location.search);
    const str = window.location.search
    function s2o (str){
      let obj = {}
      str.substr(1).split('&').forEach( item => {
        let line = item.split('=')
        obj[line[0]] = line[1]
      })
      return obj
    }
    console.log(s2o(str));


 /* 
    let str = window.location.search.substr(1);
    // console.log(str);
    let arr = str.split("&");
    // console.log(arr);
    let obj = {};
    arr.forEach(item => {
      let line = item.split("=");
      // console.log(line);
      obj[line[0]] = line[1];
    })
    console.log(obj); */
  </script>
</body>

</html>